package com.scalar.chiptrack.operations.process.forms;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import com.scalar.chiptrack.operations.process.BomSetup;
import com.scalar.chiptrack.operations.process.BomPartNumbersAndQuantity;
import com.scalar.chiptrack.commons.Constants;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by KumaraSwamy.
 * Date: May 12, 2005
 * Time: 6:09:44 PM
 */

public class BomSetupForm extends ActionForm
{
    /** Creates a new instance of BomSetupForm */
    private BomSetup bomSetup = new BomSetup();
    private String processType = Constants.LOCATION_TYPE_ASSEMBLY;

    public BomSetupForm ()
    {

    }
    public BomSetup getBomSetup() {
        return bomSetup;
    }

    public void setBomSetup(BomSetup bomSetup) {
        this.bomSetup = bomSetup;
    }

    public String getProcessType()
    {
        return processType;
    }

    public void setProcessType(String processType)
    {
        this.processType = processType;
    }

    @Override
    public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
        if(bomSetup != null && bomSetup.getBomPartNumbersAndQuantitylist() != null) {
            List list = bomSetup.getBomPartNumbersAndQuantitylist();
            for(int i=0; i < bomSetup.getBomPartNumbersAndQuantitylist().size(); i++) {
                BomPartNumbersAndQuantity bomPartNumbersAndQuantity = (BomPartNumbersAndQuantity)list.get(i);
                bomPartNumbersAndQuantity.setPrimaryPartNumber(false);
            }
        }
    }
}
